import axios from "./index";

export const refreshToken = () => {
    let r_tk = localStorage.getItem("refreshToken") //获取长token
    if (r_tk) {
        axios.get("/refresh", Object.assign({}, {
            Headers: { refreshToken: r_tk }
        }).then((res) => {
            if (res.data.code === 401) {
                localStorage.removeItem("refreshToken")
            } else if (res.data.code === 200) {
                localStorage.setItem("token", res.data.data.token)
            }
        }))
    }
}